/* FoxGUI - The fast, flexible, free Amiga GUI system
Copyright (C) 2001 Simon Fox (Foxysoft)
This library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
void ResizeEditBox(EditBox *eb, int x, int y, int len, BOOL eraseold)
{
BOOL forsublist = FALSE;
if (eb->list)
if (eb->list->Parent)
forsublist = TRUE;
resizeeditbox(eb, x, y, len, eraseold, (eb->list != NULL), forsublist);
}
/* The top, left hand corner of the editbox border will be at the EXACT
position specified in the x and y parameters passed to this function.
The coordinates of the border, the pre-text and the post-text for a
new edit box are identical to those of an output box which is created
with the same parameters. This has been THOROUGHLY tested and works
whether or not the window has a title bar and independantly of whether
or not the output box has a border.
DO NOT CHANGE ONE WITHOUT CHANGING THE OTHER - PREFERABLY DON'T CHANGE! */
static EditBox* CreateEditBox(void *Parent, int x, int y, int len, int buflen, int BorderCol, int Bcol, int Tcol, int type, int id, BOOL (* __far __stdargs callfn)(EditBox*), BOOL ForList, BOOL ForSubList, long flags)
{
EditBox *p;
GuiWindow *win;
struct TextAttr *font;
unsigned short fontheight;
Frame *ParentFrame = NULL;
Diagnostic("CreateEditBox", ENTER, TRUE);
if (!Parent)
{
Diagnostic("CreateEditBox", EXIT, FALSE);
return NULL;
}
if (!ISGUIWINDOW(Parent))
{
ParentFrame = (Frame *) Parent;
x += ParentFrame->button.LeftEdge;
y += ParentFrame->button.TopEdge;
win = (GuiWindow *) ParentFrame->button.UserData;
}
else
win = (GuiWindow *) Parent;
font = win->ParentScreen->Font;
if (font)
fontheight = font->ta_YSize;
else
fontheight = GuiFont.ta_YSize;
p = (EditBox *) GuiMalloc(sizeof(struct EditBoxStruct), 0);
SetLastErr("Window closed before all of its list boxes were destroyed.");
Diagnostic("DestroyWinDDListBoxes", EXIT, TRUE);
}
static DDListBox *CreateDDListBox(void *Parent, int x, int y, int len, int buflen, int maxheight, int BorderCol, int Bcol, int Tcol, int id, BOOL (*callfn) (DDListBox*), BOOL ForSubListBox, long flags)
{
DDListBox *p;
struct DDListBoxStruct *l;
int winheight, fontheight, xoffset = 0, yoffset = 0;
if (y + yoffset + win->Win->TopEdge + fontheight + 2 > win->ParentScreen->Height || /* Box is too low down */
x + xoffset + win->Win->LeftEdge + len + DD_LIST_BOX_BUTTON_WIDTH - 1 > win->ParentScreen->Width) /* Box is too wide or too far right */
{
Diagnostic("CreateDDListBox", EXIT, FALSE);
return NULL;
}
if (win->Win->TopEdge + y + yoffset + fontheight + 2 + winheight > win->ParentScreen->Height) /* Box cannot drop below - try above */
if (win->Win->TopEdge + y + yoffset - winheight < 0) /* Box Can't drop above */
{
Diagnostic("CreateDDListBox", EXIT, FALSE);
return NULL;
}
}
l = (struct DDListBoxStruct *) GuiMalloc(sizeof(struct DDListBoxStruct), MEMF_CLEAR);
if (!l)
{
Diagnostic("CreateDDListBox", EXIT, FALSE);
return NULL;
}
p = (DDListBox *) CreateEditBox(Parent, x, y, len, buflen, BorderCol, Bcol, Tcol, NO_EDIT, id, callfn, TRUE, ForSubListBox, flags);
if (!p)
{
GuiFree(l);
Diagnostic("CreateDDListBox", EXIT, FALSE);
return NULL;
}
p->list = l;
l->MaxHeight = maxheight;
l->TotalElems = 0;
/* On an A500, we mustn't allow the user to edit the contents of the list box (since edit hooks
aren't supported) so we need to remove the gadget to prevent the user from editing it. */
if (Gui.LibVersion < A3000)
RemoveGList(GUIWIN(p)->Win, &p->editbox, 1);
Diagnostic("CreateDDListBox", EXIT, TRUE);
return p;
}
DDListBox* FOXLIB MakeDDListBox(REGA0 void *Parent, REGD0 int x, REGD1 int y, REGD2 int len, REGD3 int buflen,
REGD4 int MaxHeight, REGD5 int id, REGA1 BOOL (* __far __stdargs callfn) (DDListBox*), REGD6 long flags, REGA2 void *extension) /* Tcol must be between 0 & 7 */
{
DDListBox *p;
Diagnostic("MakeDDListBox", ENTER, TRUE);
p = CreateDDListBox(Parent, x, y, len, buflen, MaxHeight, Gui.BorderCol, Gui.BackCol, Gui.TextCol, id, callfn, FALSE, flags);
if (p)
Diagnostic("MakeDDListBox", EXIT, TRUE);
else
Diagnostic("MakeDDListBox", EXIT, FALSE);
return p;
}
DDListBox* FOXLIB MakeSubDDListBox(REGA0 DDListBox *lb, REGA1 char *string, REGD0 int left, REGD1 int top, REGD2 int width,
REGD3 int height, REGD4 int id, REGA2 BOOL (* __far __stdargs callfn)(DDListBox*), REGA3 void *extension)